<template>
	<view class="work-list-wrap">
		<view class="uni-flex uni-column work-uni-column" v-if="list.length">
			<view class="work-flex-item" v-for="(item, index) in list" :key="item.departmentId">
				<view class="content" @click.stop="toDiningRoom(item.departmentId)">
					<view class="content-left">
						<view class="safe-circle" :style="{backgroundImage: item.backgroundImage}">
							<view class="content-title">{{item.headName}}</view>
						</view>
						<view class="department-title">{{item.departmentName}}</view>
					</view>
					<view class="content-right">
						<view class="content-abnormal-wrap">
							<view class="inspect-wrap-item">
								<view>每日检查记录&nbsp;&nbsp;{{item.alreadyNum}}/{{item.checkAllNum}}</view>
							</view>
						</view>
						<view class="content-abnormal-wrap" @click.stop="toException(item)">
							<view class="inspect-wrap-item">
								<view>异常数</view>
								<view>{{item.total || 0}}</view>
							</view>
							<view class="inspect-wrap-item even">
								<view>已处置</view>
								<view>{{item.handleCount || 0}}</view>
							</view>
							<view class="inspect-wrap-item">
								<view>未处置</view>
								<view>{{item.noHandleCount || 0}}</view>
							</view>
						</view>
					</view>
					<view class="complete-tag" v-if="item.alreadyNum===item.checkAllNum && item.checkAllNum !== 0">完成检查</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mapMutations} from 'vuex'
	export default {
		props: {
			list: {
				type: Array,
				default: () => []
			}
		},
		methods: {
			...mapMutations(['setDepartmentId']),
			toDiningRoom(id) {
				this.setDepartmentId(id)
				uni.navigateTo({
					url: `../../../pages/details/details?departmentId=${id}`
				})
				console.log('日巡查')
			},
			toException(item) {
				let {departmentId, departmentName} = item
				uni.navigateTo({
					url: `../../../pages/safeAssess/safeAssess?departmentId=${departmentId}&departmentName=${departmentName}`
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.work-list-wrap {
		.work-uni-column {
			padding: 10rpx 36rpx;
			 .work-flex-item {
				height: 300rpx;
				margin: 18rpx 0px;
				border-radius: 20rpx;
				box-shadow: 0rpx 0rpx 10rpx #ccc;
				.content {
					height: 300rpx;
					position: relative;
					padding: 0rpx 20rpx;
					box-sizing: border-box;
					display: flex;
					align-items: center;
					.content-left {
						flex: 0 0 160rpx;
						.safe-circle {
							width: 160rpx;
							height: 160rpx;
							border-radius: 100%;
							border: 1px solid #ccc;
							position: relative;
							.content-title {
								position: absolute;
								left: 50%;
								top: 50%;
								transform: translate(-50%, -50%);
								color:  $uni-bg-color;
								font-size: $uni-font-size-lg;
							}
						}
						.department-title {
							text-align: center;
							font-size: $uni-font-size-lg;
						}
					}
					.content-right {
						flex: 1;
						padding-left: 20rpx;
						font-size: $uni-font-size-lg-lg;
						.content-abnormal-wrap {
							margin: 30rpx auto;
							display: flex;
							.inspect-wrap-item {
								text-align: center;
								padding: 0rpx 24rpx;
							}
							.even {
								border-left: 1px solid #C0C0C0;
								border-right: 1px solid #C0C0C0;
							}
						}
					}
					.complete-tag {
						position: absolute;
						right: 0;
						top: 15px;
						padding: 6rpx;
						border-radius: 10rpx 0 0 10rpx;
						color: #fff;
						background: linear-gradient(to right, #44eea5, #0ddbc7);
					}
				}
			}
		}
	}
</style>
